package com.epic.services;

import com.epic.dao.assetmgr.AssetInfoMapper;
import com.epic.inter.assetmgr.IAsset;

import com.epic.po.assetmgr.AssetInfo;
import com.epic.po.assetmgr.AssetInfoExample;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

@DubboService(version = "1.0.0")
public class IAssetImpl implements IAsset {
    private static Logger logger =  LoggerFactory.getLogger(IAssetImpl.class);

    @Autowired
    private AssetInfoMapper assetInfoMapper;

    @Override
    public String testAsset(String args) {
        logger.info("enter dubbo service");
        return "hello dubbo demo " + args;
    }

    @Override
    public List<AssetInfo> getAssetList() {
        List<AssetInfo> assetInfoList = new ArrayList<AssetInfo>();
        logger.info("get asset info");
        try{
            AssetInfoExample assetInfoExample = new AssetInfoExample();
            logger.debug("enter debug mode");
            assetInfoList =  assetInfoMapper.selectByExample(assetInfoExample);
        }catch (Exception e){
            logger.info(e.getMessage());
        }
        // add spring mybatis https://mybatis.org/spring/zh/index.html
        return assetInfoList;
    }
}
